import { ResultCode } from '../src/services/dataResult';
import { Request, Response } from 'express';

let DataItemList = [
  {
    id: 1,
    name: 'Joe',
    description: 'des1',
  },
  {
    id: 2,
    name: 'Wee',
    description: 'des2',
  },
];

export default {
  'GET /demoapi/get': (req: Request, res: Response) => {
    res.status(200).send({
      code: ResultCode.Success,
      data: DataItemList[0],
      msg: 'success',
    });
  },
  'GET /demoapi/getList': (req: Request, res: Response) => {
    res.status(200).send({
      code: ResultCode.Success,
      data: DataItemList,
      msg: 'success',
      total: DataItemList.length,
    });
  },
  'POST /demoapi/add': (req: Request, res: Response) => {
    res.status(200).send({
      code: ResultCode.Success,
      data: {
        id: 10,
      },
      msg: 'success',
    });
  },
  'POST /demoapi/update': (req: Request, res: Response) => {
    res.status(200).send({
      code: ResultCode.Success,
      data: {
        id: 10,
      },
      msg: 'success',
    });
  },
  'DELETE /demoapi/deleteItem': (req: Request, res: Response) => {
    res.status(200).send({
      code: ResultCode.Success,
      data: {
        id: 10,
      },
      msg: 'success',
    });
  },
};
